home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Especial Multimedia
/
Especial Multimedia.iso
/
Multimed
/
Herra
/
SLANG10.ZIP
/
GRAF.VEC
< prev
next >
Wrap
Text File
|
1997-09-14
|
10KB
|
274 lines
addzoom(1,1)
zoom(1,1)
colorset =0
PLAY("colors.vec")
rotate(0, 0, 0)
style(SOLID_FILL, BLACK)
fill(1)
rectangle(0, 0, 1000,1000)
shifts[20]; ' We suppose to use this array for shifts with bar grafs
xar[5];
yar[5];
dar[5];
tar[6];
for i = 1 to 5
xar[i] = i
yar[i] = i^2 - 10
dar[i] = i^2 / 2
tar[i] = lg(i) * 200 ' Tick, Manual
next
tar[6] = lg(6) * 200
xd[10]; ' Deviations
yd[10];
for i = 1 to 10
xd[i] = sin(20 * i)
yd[i] = 3 + 3 * cos(10 * i^2)
next
grafclip(30, 10, 200, 200) ' Set area on screen
marker_size(8) ' Do it before call to calc_scale in the case of bar graf
' Given: Array of REAL ............................ xar
' Axe (0 - X, 1 - Y) ...................... axe
' Reset or not previous settings .......... is_first
' Justification method .................... int num_flag
'is_first indicates, is it necessary to use previous scale PLUS new data,
' or only new data.
'num_flag could be -1, 0 and 1. -1 is used for bar graphs to resize axe.
' It is necessary because few bars use additional space - and will not
' fit on graphics otherwise.
' 0 does not produce any action.
' 1 recalculate axe to produce nice-looking labels, Remember that call to
' set_axe() will automatically presume that axes are "nice-looking",
' so you MUST call set_axe() with -1 setting or not to use auto labels.
calc_scale(xar, 0, 1, -1, xd)
calc_scale(dar, 1, 1, -1) ' y-scale, first, resize
calc_scale(yar, 1, 0, -1, yd) ' y-scale, not first, resize
calc_scale(yar, 1, 0, 1) ' and fit to nice-looking scale
color(LIGHTRED) : style(SOLID_FILL, CYAN) : fill(1)
'which, text dir, tick no (-1 for auto), s_tick no<,tick_ar, s_tick_arr>
'if auto (tick_no == -1) then number of sub ticks = s_tick_no * tick no
'in this case tick_no will be 5, sub_tick_no 25
'Manual ticks setup for X:
set_axe(1, 1, -1, 5, tar, tar, "One", "Two", "Three", "Four", "Five", "Six")
'Auto setup for Y:
set_axe(2, 0, -1, 2)
'Axes numeration: HORIZ1 = 1, VERT1 = 2, HORIZ2 = 4, VERT2 = 8
axes(YELLOW, LIGHTBLUE, 0, GREEN, 3, 1, 1 + 2) 'axes color, legends color, grid style,
'grid color, axes width, ticks width, axes set (hor1 + vert1)
color(GREEN) : style(LINE_FILL, LIGHTCYAN) : fill(1)
cross() ' Draw beginning of axes (0,0)
setline(3, 0)
PLOT(xar, dar, 4, 1, shifts) ' Plot second dataset
color(CYAN) : style(CROSS_FILL, YELLOW)
PLOT(xar, yar, 4, 1, shifts) ' Plot second dataset
marker_size(4)
color(LIGHTRED) : style(SLASH_FILL, LIGHTGRAY)
setline(1, 0)
PLOT(xar, dar, 2, 1, shifts, yd, xd) ' Plot data
marker_size(8)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
for i = 1 to 20
shifts[i] = 0
next
for i = 1 to 5
yar[i] = i^2 - 10
dar[i] = i^2 / 2 - 5
next
grafclip(230, 20, 380, 210) ' Rectangle on screen
calc_scale(xar, 0, 1, 0)
calc_scale(dar, 1, 1, -1) ' y-scale, first, resize
calc_scale(yar, 1, 0, -1) ' y-scale, not first, resize
calc_scale(yar, 1, 0, 1)
calc_scale(xar, 0, 0, 1)
set_axe(1, 0, -1, 2)
set_axe(2, 0, -1, 2)
set_axe(4, 0, -1, 5)
set_axe(8, 0, -1, 2)
'Axes numeration: HORIZ1 = 1, VERT1 = 2, HORIZ2 = 4, VERT2 = 8
axes(YELLOW, LIGHTRED, 0, LIGHTGRAY, 3, 1, 1 + 2 + 4 + 8) 'axes color, legends color, grid style,
'grid color, axes width, ticks width, axes set (hor1 + vert1)
color(LIGHTCYAN) : style(LINE_FILL, CYAN)
cross() ' Draw beginning of axes (0,0)
PLOT(xar, yar, 5, 1, shifts) ' Plot dataset
color(DARKGRAY) : style(SLASH_FILL, GREEN)
PLOT(xar, dar, 5, 1, shifts) ' Plot second dataset
for i = 1 to 20
shifts[i] = 0
next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
rar[100];
sar[100];
for i = 1 to 100
rar[i] = i
sar[i] = sin(3.6 * i)
next
grafclip(420, 20, 600, 210) ' Clip rectangle on screen
grafscale(0, -1, 100, 2) 'Manual scale ajustment
'calc_scale(rar, 0, 0, 1) ' x-scale, not first, resize
'calc_scale(sar, 1, 0, 1) ' y-scale, not first, no resize
'calc_scale(sar, 1, 1, 1) ' and fit to nice-looking scale
set_axe(1, 0, -1, 2)
set_axe(2, 0, -1, 2)
set_axe(4, 0, -1, 2)
set_axe(8, 0, -1, 2)
'Axes numeration: HORIZ1 = 1, VERT1 = 2, HORIZ2 = 4, VERT2 = 8
axes(YELLOW, LIGHTRED, 3, LIGHTGRAY, 3, 1, 1 + 2 + 4 + 8) 'axes color, legends color, grid style,
'grid color, axes width, ticks width, axes set (hor1 + vert1)
cross() ' (0, 0)
color(LIGHTGREEN) : style(SOLID_FILL, GREEN) : setline(3, 0)
PLOT(rar, sar, 1, 1, shifts) ' Plot dataset
for i = 1 to 20
shifts[i] = 0
next
setline(1, 1)
''''''''''''''''''''''''''''''''' Add small graph at the corner of big one
'''''''''''''''''''''''''''''''''
for i = 1 to 100
sar[i] = 100 * sar[i]
next
setline(1, 0)
grafclip(510, 35, 595, 90) ' Clip rectangle on screen
style(SOLID_FILL, BLACK) : fill(1)
rectangle(480, 20, 600, 120)
calc_scale(rar, 0, 1, 0) ' x-scale, first, resize
calc_scale(sar, 1, 1, 0) ' y-scale, first, no resize
'calc_scale(sar, 1, 0, 1) ' and fit to nice-looking scale
set_axe(1, 1, -1, 0)
set_axe(2, 0, -1, 0)
'set_axe(4, 1, -1, 0)
'set_axe(8, 0, -1, 0)
'Axes numeration: HORIZ1 = 1, VERT1 = 2, HORIZ2 = 4, VERT2 = 8
axes(YELLOW, LIGHTRED, 3, LIGHTGRAY, 3, 1, 1 + 2) 'axes color, legends color, grid style,
'grid color, axes width, ticks width, axes set (hor1 + vert1)
cross() ' (0, 0)
color(LIGHTGREEN) : style(SOLID_FILL, GREEN) : setline(3, 0)
PLOT(rar, sar, 1, 1, shifts) ' Plot dataset
for i = 1 to 20
shifts[i] = 0
next
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
marker_size(16)
zar[20];
' We set zar[] manually. The rules are:
' zar[4*i+1] keep ystart < 0;
' zar[4*i+2] keep ystart >= 0;
' zar[4*i+3] keep yend < 0;
' zar[4*i+4] keep yend >= 0;
zar[1] = 0 : zar[2] = 0 : zar[3] = 0 : zar[4] = 10
zar[5] = 0 : zar[6] = 0 : zar[7] = 0 : zar[8] = 24
zar[9] = 0 : zar[10] = 0 : zar[11] = 0 : zar[12] = 15
zar[13] = 0 : zar[14] = 0 : zar[15] = 0 : zar[16] = 10
zar[17] = 0 : zar[18] = 0 : zar[19] = 0 : zar[20] = 5
aar[20];
aar[1] = 0 : aar[2] = 10 : aar[3] = 0 : aar[4] = 12
aar[5] = 0 : aar[6] = 24 : aar[7] = 0 : aar[8] = 25
aar[9] = 0 : aar[10] = 15 : aar[11] = 0 : aar[12] = 25
aar[13] = 0 : aar[14] = 10 : aar[15] = 0 : aar[16] = 15
aar[17] = 0 : aar[18] = 5 : aar[19] = 0 : aar[20] = 7
grafclip(20, 250, 240, 420)
calc_scale(xar, 0, 1, 0) ' x-scale, first, no resize
calc_scale(zar, 1, 1, 0) ' y-scale, first, resize
calc_scale(aar, 1, 0, -1) ' y-scale, not first, no resize
' That is not necessary to resize
get_axes_dim(xmin, ymin, xmax, ymax)
grafscale(xmin, ymin * 1.2, xmax, ymax * 1.2)
calc_scale(xar, 0, 0, 1)
set_axe(1, 0, -1, 5)
set_axe(2, 0, -1, 2)
set_axe(4, 0, -1, 5)
set_axe(8, 0, -1, 2)
'Axes numeration: HORIZ1 = 1, VERT1 = 2, HORIZ2 = 4, VERT2 = 8
axes(YELLOW, LIGHTRED, 0, LIGHTGRAY, 3, 1, 1 + 2 + 4 + 8) 'axes color, legends color, grid style,
'grid color, axes width, ticks width, axes set (hor1 + vert1)
color(LIGHTGRAY) : style(CROSS_FILL, GREEN)
cross() ' Stacked Graf twice
setline(3, 0)
PLOT(xar, zar, 6, 3)
color(YELLOW) : style(LINE_FILL, LIGHTBLUE)
PLOT(xar, aar, 6, 3)
setline(1, 0)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Now we combine manual and automatic approaches: first two arrays are
' composed manually, third is added with call to get_stacked()
' zar[4*i+1] keep ystart < 0;
' zar[4*i+2] keep ystart >= 0;
' zar[4*i+3] keep yend < 0;
' zar[4*i+4] keep yend >= 0;
bar[20];
bar[1] = 0 : bar[2] = 0 : bar[3] = -10 : bar[4] = 10
bar[5] = 0 : bar[6] = 0 : bar[7] = -20 : bar[8] = 10
bar[9] = 0 : bar[10] = 0 : bar[11] = 0 : bar[12] = 10
bar[13] = 0 : bar[14] = 0 : bar[15] = 0 : bar[16] = 20
bar[17] = 0 : bar[18] = 0 : bar[19] = 0 : bar[20] = 2
car[20];
car[1] = -10 : car[2] = 10 : car[3] = -15 : car[4] = 20
car[5] = -20 : car[6] = 10 : car[7] = -25 : car[8] = 15
car[9] = 0 : car[10] = 10 : car[11] = 0 : car[12] = 17
car[13] = 0 : car[14] = 20 : car[15] = 0 : car[16] = 22
car[17] = 0 : car[18] = 2 : car[19] = 0 : car[20] = 12
grafclip(310, 250, 550, 450)
@last_graf()
rotate(45, 250, 250)
style(SOLID_FILL, BLACK)
rectangle(150, 150, 450, 400)
grafclip(180, 180, 420, 370)
@last_graf()
END
@last_graf()
color(LIGHTBLUE) : style(LINE_FILL, BLUE)
ear[20];
for i = 1 to 20
ear[i] = car[i]
next
calc_scale(xar, 0, 1, 0) ' x-scale, first, no resize
get_stacked(xar, ear) ' ear scale is enought
calc_scale(ear, 1, 0, -1) ' y-scale, first, resize
get_axes_dim(xmin, ymin, xmax, ymax)
grafscale(xmin, ymin * 1.2, xmax, ymax * 1.2)
calc_scale(xar, 0, 0, 1)
calc_scale(ear, 1, 0, 1)
set_axe(1, 0, -1, 5)
set_axe(2, 0, -1, 2)
set_axe(4, 0, -1, 5)
set_axe(8, 0, -1, 2)
'Axes numeration: HORIZ1 = 1, VERT1 = 2, HORIZ2 = 4, VERT2 = 8
axes(YELLOW, LIGHTRED, 0, LIGHTGRAY, 3, 1, 1 + 2 + 4 + 8) 'axes color, legends color, grid style,
'grid color, axes width, ticks width, axes set (hor1 + vert1)
cross()
color(LIGHTBLUE) : style(SLASH_FILL, BLUE) : setline(3, 0)
PLOT(xar, bar, 6, 3)
color(LIGHTCYAN) : style(LINE_FILL, BROWN)
PLOT(xar, car, 6, 3)
color(LIGHTGREEN) : style(CROSS_FILL, LIGHTRED)
PLOT(xar, ear, 6, 3)
setline(1, 0)
return